<%@ Page Language="C#" AutoEventWireup="true" Theme="YUI" CodeFile="Courses.aspx.cs"
    Inherits="Home_Courses" %>

<%@ Register Src="../UserControls/Menu.ascx" TagName="Menu" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>PlacementManager: Courses</title>

    <script language="javascript" type="text/javascript">
    function showToolTip(e,text){ 
      var ToolTip = document.getElementById("ToolTip");
      ToolTip.innerHTML=text; 
      ToolTip.style.left=(e.clientX+15+document.body.scrollLeft)+'px'; 
      ToolTip.style.top=(e.clientY+document.body.scrollTop)+'px';  
      ToolTip.style.display="block";
    } 
    function hideToolTip(){ 
        var ToolTip = document.getElementById("ToolTip");
        ToolTip.style.display="none"; 
    } 
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="True">
        </ajaxToolkit:ToolkitScriptManager>
        <div id="ToolTip" style="position: absolute; z-index: 1000; text-align: left; display: none;">
        </div>
        <div id="doc3" class="yui-t1">
            <div id="hd">
                <asp:Panel ID="pnlMenu" runat="server">
                    <uc1:Menu ID="Menu1" runat="server" />
                </asp:Panel>
            </div>
            <div id="bd">
                <div class="yui-b">
                    <asp:UpdatePanel ID="updtpnlVenuesGrid" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnInsertCourse" EventName="Click" />
                        </Triggers>
                        <ContentTemplate>
                            <asp:GridView ID="gvCourses" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                DataKeyNames="CourseId" DataSourceID="odsCourses_GV" OnRowUpdating="gvCourses_RowUpdating"
                                PageSize="20" SelectedIndex="0" SkinID="Results" OnSelectedIndexChanged="gvCourses_SelectedIndexChanged"
                                OnDataBound="gvCourses_DataBound" OnRowDataBound="gvCourses_RowDataBound">
                                <Columns>
                                    <asp:CommandField ButtonType="Image" SelectImageUrl="~/Images/Icons/edit.gif" SelectText="Edit Course"
                                        ShowSelectButton="True" />
                                    <asp:BoundField DataField="CourseCode" HeaderText="Course Code" SortExpression="CourseCode" />
                                </Columns>
                                <EmptyDataTemplate>
                                    No Courses Defined.
                                </EmptyDataTemplate>
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <div id="yui-main">
                    <div class="yui-b">
                        <span style="font-size: large; font-weight: bold; float: left;">Manage Courses</span>
                        <asp:UpdateProgress ID="updtprogVenuesGrid" runat="server" AssociatedUpdatePanelID="updtpnlVenuesGrid"
                            DisplayAfter="2" DynamicLayout="false">
                            <ProgressTemplate>
                                &nbsp; &nbsp;&nbsp;
                                <img alt="Progress" src="../Images/progressbar_long_green.gif" />
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <span style="clear: both"></span>
                        <div class="yui-gc">
                            <!-- the "special grid" -->
                            <div class="yui-u first">
                                <asp:UpdatePanel ID="updtpnlCourseDetails" runat="server" UpdateMode="Conditional">
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="gvCourses" EventName="SelectedIndexChanged" />
                                    </Triggers>
                                    <ContentTemplate>
                                        <asp:FormView ID="fvCourse" runat="server" DataSourceID="odsCourse_DV" OnItemUpdated="fvCourse_ItemUpdated"
                                            OnItemUpdating="fvCourse_ItemUpdating">
                                            <EditItemTemplate>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <span class="formLabel">Course Code:</span>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="CourseCodeTextBox" runat="server" Text='<%# Bind("CourseCode") %>'
                                                                MaxLength="256" Width="450"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <span class="formLabel">Course Name:</span>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="CourseNameTextBox" runat="server" Text='<%# Bind("CourseName") %>'
                                                                MaxLength="256" Width="450"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CssClass="inputbutton"
                                                                CommandName="Update" Text="Update"></asp:Button>
                                                            <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CssClass="inputbutton"
                                                                CommandName="Cancel" Text="Cancel"></asp:Button>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <h2>
                                                    <asp:Label ID="CourseCodeLabel" runat="server" Text='<%# Bind("CourseCode") %>'></asp:Label>
                                                    -
                                                    <asp:Label ID="CourseNameLabel" runat="server" Text='<%# Bind("CourseName") %>'></asp:Label></h2>
                                                <table style="width: 400px;">
                                                    <tr>
                                                        <td style="width: 100px;">
                                                            <span class="formLabel">DateCreated:</span></td>
                                                        <td style="width: 300px;">
                                                            <asp:Label ID="DateCreatedLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "DateCreated", "{0:dddd d MMMM}") %>'></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 100px;">
                                                            <span class="formLabel">CreatedBy:</span></td>
                                                        <td>
                                                            <asp:Label ID="CreatedByLabel" runat="server" Text='<%# Bind("CreatedBy") %>'></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 100px;">
                                                            <span class="formLabel">DateUpdated:</span></td>
                                                        <td>
                                                            <asp:Label ID="DateUpdatedLabel" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "DateUpdated", "{0:dddd d MMMM}") %>'></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 100px;">
                                                            <span class="formLabel">UpdatedBy:</span></td>
                                                        <td>
                                                            <asp:Label ID="UpdatedByLabel" runat="server" Text='<%# Bind("UpdatedBy") %>'></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="Edit" CssClass="inputbutton" /></td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </asp:FormView>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                                <asp:Label ID="lblNoCourseSelected" runat="server" Text="No course information is available."
                                    Visible="False"></asp:Label>&nbsp;
                                <asp:Label ID="lblNoCourseForUnits" runat="server" Text="No course is selected."
                                    Visible="False"></asp:Label>
                                <br />
                                <br />
                                <h2>
                                    Add New Course</h2>
                                <br />
                                <table>
                                    <tr>
                                        <td class="formLabel" style="width: 150px">
                                            <asp:Label ID="lblCourseCode" runat="server" Text="New Course Code:"></asp:Label></td>
                                        <td>
                                            <asp:TextBox ID="txtCourseCode" runat="server" MaxLength="50"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td class="formLabel" style="width: 150px">
                                            <asp:Label ID="lblCourseName" runat="server" Text="New Course Name:"></asp:Label></td>
                                        <td>
                                            <asp:TextBox ID="txtCourseName" runat="server" MaxLength="255"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 150px">
                                        </td>
                                        <td>
                                            <asp:Button ID="btnInsertCourse" runat="server" CssClass="inputbutton" OnClick="btnInsertCourse_Click"
                                                Text="Insert Course" /></td>
                                    </tr>
                                </table>
                            </div>
                            <div class="yui-u">
                                <asp:UpdatePanel ID="updtpnlUnitsForCourses" runat="server" UpdateMode="Conditional">
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="gvCourses" EventName="SelectedIndexChanged" />
                                    </Triggers>
                                    <ContentTemplate>
                                        <asp:Label runat="server" ID="lblUnitsForCourse" CssClass="formLabel"></asp:Label>
                                        <asp:GridView ID="gvUnits" runat="server" AutoGenerateColumns="False" DataKeyNames="UnitId"
                                            DataSourceID="odsUnits_GV" EmptyDataText="No units have been allocated to this course."
                                            OnRowCommand="gvUnits_RowCommand" SkinID="Results" ShowHeader="False" OnRowDataBound="gvUnits_RowDataBound">
                                            <Columns>
                                                <asp:ButtonField ButtonType="Image" CommandName="DeleteUnitLink" ImageUrl="~/Images/Icons/x.gif"
                                                    Text="Remove Link" />
                                                <asp:BoundField DataField="UnitCode" HeaderText="UnitCode" SortExpression="UnitCode" />
                                            </Columns>
                                        </asp:GridView>
                                        <span class="formLabel">Available units:</span><br />
                                        <asp:ListBox ID="lbAvailableUnitsForCourse" runat="server" DataSourceID="odsAvailableUnits_LB"
                                            DataTextField="UnitCode" DataValueField="UnitId" SelectionMode="Multiple" ToolTip="Select the units that you want to add to this course."
                                            OnDataBound="lbAvailableUnitsForCourse_DataBound"></asp:ListBox>
                                        <br />
                                        <asp:Button ID="btnAddUnitsToCourse" runat="server" CssClass="inputbutton" OnClick="btnAddUnitsToCourse_Click"
                                            Text="Add Units" />
                                        <br />
                                        <asp:Label ID="lblNoUnitsAvailable" runat="server" Text="No units are available to be added."
                                            Visible="False"></asp:Label>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="ft">
            &nbsp;
        </div>
        <!--Object Data Sources ************************************************* -->
        <asp:ObjectDataSource ID="odsCourses_GV" runat="server" DataObjectTypeName="PlacementManager.Course"
            SelectMethod="SelectAllWDivisionId" SortParameterName="sortExpression" TypeName="PlacementManager.CourseComponent"
            UpdateMethod="Update" DeleteMethod="DeleteAllWDivisionId" InsertMethod="Insert"
            OldValuesParameterFormatString="original_{0}">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="1" Name="DivisionId" SessionField="DivisionId"
                    Type="Int32" />
                <asp:Parameter DefaultValue="CourseCode" Name="sortExpression" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="DivisionId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="DivisionId" Type="Int32" />
                <asp:Parameter Name="CourseCode" Type="String" />
                <asp:Parameter Name="CourseName" Type="String" />
                <asp:Parameter Name="IsActive" Type="Boolean" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
                <asp:Parameter Name="CreatedBy" Type="String" />
                <asp:Parameter Name="DateUpdated" Type="DateTime" />
                <asp:Parameter Name="UpdatedBy" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsCourse_DV" runat="server" DataObjectTypeName="PlacementManager.Course"
            SelectMethod="SelectOne" TypeName="PlacementManager.CourseComponent" UpdateMethod="Update">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvCourses" Name="CourseId" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsUnits_GV" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
            OldValuesParameterFormatString="original_{0}" SelectMethod="SelectAllWCourseId"
            TypeName="PlacementManager.UnitComponent" UpdateMethod="Update">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvCourses" Name="courseId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="UnitCode" Name="sortExpression" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="UnitId" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="UnitId" Type="Int32" />
                <asp:Parameter Name="UnitCode" Type="String" />
                <asp:Parameter Name="UnitName" Type="String" />
                <asp:Parameter Name="YearLevel" Type="Int32" />
                <asp:Parameter Name="IsActive" Type="Boolean" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
                <asp:Parameter Name="CreatedBy" Type="String" />
                <asp:Parameter Name="DateUpdated" Type="DateTime" />
                <asp:Parameter Name="UpdatedBy" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="UnitCode" Type="String" />
                <asp:Parameter Name="UnitName" Type="String" />
                <asp:Parameter Name="YearLevel" Type="Int32" />
                <asp:Parameter Name="IsActive" Type="Boolean" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
                <asp:Parameter Name="CreatedBy" Type="String" />
                <asp:Parameter Name="DateUpdated" Type="DateTime" />
                <asp:Parameter Name="UpdatedBy" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAvailableUnits_LB" runat="server" DeleteMethod="DeleteAllWDivisionId"
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="SelectAllWithoutCourseId"
            TypeName="PlacementManager.UnitComponent" UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="DivisionId" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="UnitId" Type="Int32" />
                <asp:Parameter Name="UnitCode" Type="String" />
                <asp:Parameter Name="UnitName" Type="String" />
                <asp:Parameter Name="DivisionId" Type="Int32" />
                <asp:Parameter Name="YearLevel" Type="Int32" />
                <asp:Parameter Name="IsActive" Type="Boolean" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
                <asp:Parameter Name="CreatedBy" Type="String" />
                <asp:Parameter Name="DateUpdated" Type="DateTime" />
                <asp:Parameter Name="UpdatedBy" Type="String" />
            </UpdateParameters>
            <SelectParameters>
                <asp:SessionParameter DefaultValue="1" Name="divisionId" SessionField="DivisionId"
                    Type="Int32" />
                <asp:ControlParameter ControlID="gvCourses" Name="courseId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="UnitCode" Name="sortExpression" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="UnitCode" Type="String" />
                <asp:Parameter Name="UnitName" Type="String" />
                <asp:Parameter Name="DivisionId" Type="Int32" />
                <asp:Parameter Name="YearLevel" Type="Int32" />
                <asp:Parameter Name="IsActive" Type="Boolean" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
                <asp:Parameter Name="CreatedBy" Type="String" />
                <asp:Parameter Name="DateUpdated" Type="DateTime" />
                <asp:Parameter Name="UpdatedBy" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
    </form>
</body>
</html>
